package work.atpgroup.service.impl;

import org.springframework.stereotype.Service;
import work.atpgroup.entity.Identity;
import work.atpgroup.entity.User;
import work.atpgroup.mapper.IdentityMapper;
import work.atpgroup.mapper.UserMapper;
import work.atpgroup.mapper.union.UserIdentityMapper;
import work.atpgroup.service.IdentityService;

import javax.annotation.Resource;
import java.util.List;
@Service("identityService")
public class IdentityServiceImpl implements IdentityService {
    @Resource(name="userIdentityMapper")
    private UserIdentityMapper userIdentityMapper;

    @Resource(name="identityMapper")
    private IdentityMapper identityMapper;
    @Resource(name="userMapper")
    private UserMapper userMapper;
    @Override
    public int insertIdentity(Identity identity) {
        return identityMapper.insertIdentity(identity);
    }

    @Override
    public int deleteIdentity(Integer identityId) {
        return identityMapper.deleteIdentity(identityId);
    }

    @Override
    public int updateIdentity(Identity identity) {
        return identityMapper.updateIdentity(identity);
    }

    @Override
    public Identity getIdentityById(Integer identityId) {
        return identityMapper.getIdentityById(identityId);
    }

    @Override
    public List<User> getUserWithThisIdentity(Identity identity) {
        return getUserWithThisIdentity(identity.getIdentityId());
    }

    @Override
    public List<User> getUserWithThisIdentity(Integer identityId) {
        return userMapper.getUserByListId(userIdentityMapper.getEveryUserIdWithThisIdentity(identityId));
    }
}
